from django.db import models

# Create your models here.
# 如果将一个普通的类变为可以映射到数据库的ORM模型
# 需要继承models.Medel


class Book(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=100, null=False)
    author = models.CharField(max_length=100, null=False)
    price = models.FloatField(default=0, null=False)
    # 指定名字

    class Meta:
        db_table = "book"


class Pub(models.Model):
    # 如果不写主键，django会自动生成一个id为自增长的逐渐
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=100, null=False)
    add = models.CharField(max_length=100, null=False)

    class Meta:
        db_table = "publisher"
